<template>
	<el-card class="collection">
		<el-form :model="datas" label-width="80px" style="width: 200px" label-position="top">
			<el-form-item label="采集姓名">
				<el-switch v-model="datas.phone" />
			</el-form-item>
			<el-form-item label="采集电话">
				<el-switch v-model="datas.name" />
			</el-form-item>
			<el-form-item label="采集工地">
				<el-switch v-model="datas.location" />
			</el-form-item>
			<el-form-item label="">
				<el-button type="primary" @click="onsubmit">保存</el-button>
			</el-form-item>
		</el-form>
	</el-card>
</template>
<script setup lang="ts">
import { reactive } from 'vue';
import { getMsgConfig, updateMsgConfig } from '@/utils/api';
import { ElMessage } from 'element-plus';
const datas = reactive({
	phone: false,
	name: false,
	location: false,
});
const getDatas = () => {
	getMsgConfig().then((res: any) => {
		let data = res.data;
		datas.location = data.location;
		datas.name = data.name;
		datas.phone = data.phone;
	});
};
getDatas();
const onsubmit = () => {
	updateMsgConfig(datas).then((res: any) => {
		ElMessage.success('保存成功');
	});
};
</script>
